﻿using DiffuseEnjoyIdle.Core.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace System.Linq
{
    public class ParamItem
    {
        public PropertyInfo Prop { get; private set; }

        public Enum_ConditionType OpType { get; private set; }

        public string MatchName { get; internal set; }

        public ParamItem(PropertyInfo prop, string name)
        {
            Prop = prop;
            Name2Type(name);
        }

        private void Name2Type(string name)
        {
            IExpressionBuilder[] builderList = Ext.BuilderList;
            foreach (IExpressionBuilder expressionBuilder in builderList)
            {
                if (!string.IsNullOrEmpty(expressionBuilder.EndKey) && name.EndsWith(expressionBuilder.EndKey))
                {
                    OpType = expressionBuilder.OpType;
                    MatchName = name.Substring(0, name.Length - expressionBuilder.EndKey.Length);
                    return;
                }
            }

            OpType = Enum_ConditionType.Equal;
            MatchName = name;
        }
    }
}